import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Student Grade Management System
 *
 * This program allows recording and querying of student grades.
 */
public class StudentScoreSystem {

    // Map to store student grades (student name -> grade)
    private static Map<String, Double> gradeBook = new HashMap<>();
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        System.out.println("Student Grade Management System");

        while (true) {
            System.out.println("\nOptions:");
            System.out.println("1. Record a student grade");
            System.out.println("2. Query a student grade");
            System.out.println("3. Exit");
            System.out.print("Enter your choice: ");

            int choice = scanner.nextInt();
            scanner.nextLine(); // consume newline

            switch (choice) {
                case 1:
                    recordGrade();
                    break;
                case 2:
                    queryGrade();
                    break;
                case 3:
                    System.out.println("Exiting system...");
                    return;
                default:
                    System.out.println("Invalid choice. Please try again.");
            }
        }
    }

    /**
     * Records a student's grade in the system.
     */
    private static void recordGrade() {
        System.out.print("Enter student name: ");
        String name = scanner.nextLine();

        System.out.print("Enter student grade: ");
        double grade = scanner.nextDouble();
        scanner.nextLine(); // consume newline

        gradeBook.put(name, grade);
        System.out.println("Grade recorded successfully for " + name);
    }

    /**
     * Queries and displays a student's grade.
     */
    private static void queryGrade() {
        System.out.print("Enter student name to query: ");
        String name = scanner.nextLine();

        Double grade = gradeBook.get(name);
        if (grade != null) {
            System.out.println(name + "'s grade is: " + grade);
        } else {
            System.out.println("No grade found for " + name);
        }
    }
}